package com.ruoyi.basedocument.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedocument.domain.BomSeasontype;
import com.ruoyi.basedocument.service.IBomSeasontypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时间类型Controller
 * 
 * @author ruoyi
 * @date 2024-09-05
 */
@RestController
@RequestMapping("/bomcostestimation/basedocument/seasontype")
public class BomSeasontypeController extends BaseController
{
    @Autowired
    private IBomSeasontypeService bomSeasontypeService;

    /**
     * 查询时间类型列表
     */
    @PreAuthorize("@ss.hasPermi('bomcostestimation/basedocument:seasontype:list')")
    @GetMapping("/list")
    public TableDataInfo list(BomSeasontype bomSeasontype)
    {
        startPage();
        List<BomSeasontype> list = bomSeasontypeService.selectBomSeasontypeList(bomSeasontype);
        return getDataTable(list);
    }

    /**
     * 导出时间类型列表
     */
    @PreAuthorize("@ss.hasPermi('bomcostestimation/basedocument:seasontype:export')")
    @Log(title = "时间类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BomSeasontype bomSeasontype)
    {
        List<BomSeasontype> list = bomSeasontypeService.selectBomSeasontypeList(bomSeasontype);
        ExcelUtil<BomSeasontype> util = new ExcelUtil<BomSeasontype>(BomSeasontype.class);
        util.exportExcel(response, list, "时间类型数据");
    }

    /**
     * 获取时间类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('bomcostestimation/basedocument:seasontype:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") String fid)
    {
        return success(bomSeasontypeService.selectBomSeasontypeByFid(fid));
    }

    /**
     * 新增时间类型
     */
    @PreAuthorize("@ss.hasPermi('bomcostestimation/basedocument:seasontype:add')")
    @Log(title = "时间类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BomSeasontype bomSeasontype)
    {
        return toAjax(bomSeasontypeService.insertBomSeasontype(bomSeasontype));
    }

    /**
     * 修改时间类型
     */
    @PreAuthorize("@ss.hasPermi('bomcostestimation/basedocument:seasontype:edit')")
    @Log(title = "时间类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BomSeasontype bomSeasontype)
    {
        return toAjax(bomSeasontypeService.updateBomSeasontype(bomSeasontype));
    }

    /**
     * 删除时间类型
     */
    @PreAuthorize("@ss.hasPermi('bomcostestimation/basedocument:seasontype:remove')")
    @Log(title = "时间类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable String[] fids)
    {
        return toAjax(bomSeasontypeService.deleteBomSeasontypeByFids(fids));
    }
}
